import java.io.*;
import java.util.*;

public class Main {
	private BufferedReader bf;
	private StringTokenizer st;
	private StringBuilder sb;
	
	private final int[] dx = new int[] {1, -1, 0, 0},
						dy = new int[] {0, 0, -1, 1};
	private final char road = '0',
					   wall = '1',
					   rightWay = '#';
	private int n;
	private char[][] maze;
	private boolean[][] visited;
	
	public Main() {
		bf = new BufferedReader(new InputStreamReader(System.in));
		sb = new StringBuilder();
	}

	public static void main(String[] args) {
		Main main = new Main();
		main.process();
	}
	
	public void process() {
		try {
			String input;
			int i,
				j;
			
			while((input = bf.readLine()) != null) {
				st = new StringTokenizer(input);
				n = st.countTokens();
				maze = new char[n][n];
				visited = new boolean[n][n];
				for(i = 0; i < n; i++)
					for(j = 0; j < n; j++)
						visited[i][j] = false;
				
				for(j = 0; j < n; j++)
					maze[0][j] = st.nextToken().charAt(0);
				
				for(i = 1; i < n; i++) {
					st = new StringTokenizer(bf.readLine());
					for(j = 0; j < n; j++)
						maze[i][j] = st.nextToken().charAt(0);
				}
				
				dfs(1, 1);
				getResult();
			}
			System.out.print(sb);
		}
		catch(Exception ex) {
			System.err.println(ex.toString());
		}
	}
	
	private void dfs(int x, int y) {
		if(visited[x][y]) return;
		
		visited[x][y] = true;
		
		if(x == n - 2 && y == n - 2) {
			maze[x][y] = rightWay;
			return;
		}
		
		int i,
			nx,
			ny;
		for(i = 0; i < dx.length; i++) {
			nx = x + dx[i];
			ny = y + dy[i];
			if(maze[nx][ny] == road) {
				dfs(nx, ny);
				if(maze[nx][ny] == rightWay) {
					maze[x][y] = rightWay;
					return;
				}
			}
		}
	}
	
	private void getResult() {
		int i,
			j;
		for(i = 0; i < n; i++) {
			for(j = 0; j < n; j++)
				sb.append(maze[i][j]+ " ");
			sb.delete(sb.length() - 1, sb.length());
			sb.append("\n");
		}
	}
	
}